package cn.szzsi.heartbeat;


import cn.szzsi.core.dubbo.PayDubboService;
import cn.szzsi.core.healthCheck.HealthCheckTask;
import cn.szzsi.payservice.HealthCheckInterface;
import com.jfinal.core.Controller;
import com.jfinal.plugin.redis.Redis;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2017/8/11.
 */
public class HealthCheckController extends Controller {
    static HealthCheckTask healthCheckTask = HealthCheckTask.me;
    public void check(){
        renderJson(healthCheckTask.check());
        return;
    }
    public void dubboHealthCheck() {
        Integer in= PayDubboService.getInstance().imports(HealthCheckInterface.class).dubboHealthCheck();
        Redis.use("zshop").set("date",new Date());
        Date date=Redis.use("zshop").get("date");
        SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("zshop调用pay项目健康检查接口dubboHealthCheck返回"+in);
        System.out.println("zshop调用Redis健康检查返回当前时间"+sdf1.format(date));
        renderJson(in);
        return;
    }
    /**
     * 测试异常监控
     */
    public void test1(){
        Integer integer =Integer.parseInt("ggg");
        renderNull();
        return;
    }
}
